import cookies from './util.cookies'

const util = {
  cookies
}

function tTitle (title = '') {
  if (window && window.$t) {
    if (title.indexOf('$t:') === 0) {
      return window.$t(title.split('$t:')[1])
    } else {
      return title
    }
  } else {
    return title
  }
}

/**
 * @description 更改标题
 * @param {Object} title 标题
 * @param {Object} count 未读消息数提示（可视情况选择使用或不使用）
 */
util.title = function (title) {
  title = tTitle(title)
  window.document.title = title
}

export const requestAnimation = (task) => {
  if ('requestAnimationFrame' in window) {
    return window.requestAnimationFrame(task)
  }

  setTimeout(task, 16)
}

export { requestAnimation }

export default util
